#pragma once
#include <vector>
#include <string>
#include <libserial/SerialPort.h>
#include <rclcpp/rclcpp.hpp>
#include <mutex>

class SerialDriver {
public:
    void Setup(const std::string& port, int baud);
    void Write(const std::vector<uint8_t>& data);
    void Close();
    bool IsOpen() const;
    bool ReadByte(uint8_t &byte, int timeout_ms);
    
private:
    LibSerial::SerialPort serial_port_;
    mutable std::mutex serial_mutex_;
};